package com.bw.ivideoproject.home

import androidx.room.Room
import com.bw.ivideoproject.App
import com.bw.ivideoproject.db.entity.HistoryEntity
import com.bw.ivideoproject.entity.*
import com.bw.lib_mvvm.BaseModel

class HomeModel : BaseModel(){

    val api = getVideoService(HomeApi::class.java)

    suspend fun getSimpleVideoType():BaseResp<List<SimpleVideoTypeEntity>>{
        return api.getSimpleVideoType()
    }

    suspend fun getSimpleVideo(channelId:String,page:Int,pageSize:Int):BaseResp<List<SimpleVideoEntity>>{
        return api.getSimpleVideo(channelId, page, pageSize)
    }

    suspend fun getRecommendVideo(page:Int,pageSize:Int):BaseResp<List<SimpleVideoEntity>>{
        return api.getRecommendVideo(page, pageSize)
    }

    suspend fun getComment(dataType:Int,itemId:String):BaseResp<List<CommentEntity>>{
        return api.getComment(dataType,itemId)
    }

    suspend fun sendComment(entity: CommentEntity):BaseResp<CommentEntity>{
        return api.sendComment(entity)
    }

//    fun getHistorySearch():Array<HistoryEntity>{
//        return db.getHistoryDao().getAll()
//    }
//
//    fun insertSearch(entity:HistoryEntity){
//        return db.getHistoryDao().insert(entity)
//    }

    suspend fun getVideoByKeyword(keyword:String,page:Int,pageSize:Int):BaseResp<List<SimpleVideoEntity>>{
        return api.getVideoByKeyword(keyword, page, pageSize)
    }

}